home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / drivefnd.arc / DRIVEFND.PAS next >
Pascal/Delphi Source File  |  1991-04-28  |  2KB  |  101 lines

  1. Unit Drivefnd ;
  2.  
  3. Interface
  4.  
  5. uses crt, dos;
  6.  
  7. var
  8.    R               : Registers ;
  9.    k,
  10.    j,
  11.    i,
  12.    MaxDrives,                     { total number of drives from DOS - maybe more than we have }
  13.    NumbDrives,                    { total number of floppy and hard disk drives }
  14.    NumbHardDrives,                { total number of hard disk drives }
  15.    EquipmentList,                 { list of equipment from DOS }
  16.    NumbFloppies,                  { total number of floppy disk drives }
  17.    ErrorCode       : integer ;
  18.  
  19.    Ans             : char ;
  20.    Drives          : string[26] ;
  21.    DriveSet        : set of 'A'..'Z' ;
  22.  
  23. { procedures and functions }
  24.  
  25. Procedure FindDrives ;
  26.  
  27.  
  28. Implementation
  29.  
  30. Procedure BiosCall(AH,AL,BH,BL:Byte) ;
  31.  
  32. var
  33.    R               : Registers ;
  34.  
  35. begin
  36.    R.AH := AH ;
  37.    R.AL := AL ;
  38.    R.BH := BH ;
  39.    R.BL := BL ;
  40.    Intr($10,R) ;
  41.  
  42. {   Writeln ('AH = ',R.AH,'  AL = ',R.AL,'BH = ',R.BH,'  BL = ',R.BL) ;}
  43. end ;
  44.  
  45.  
  46. Procedure FindDrives ;
  47.  
  48. begin
  49.    DriveSet := [] ;                 { start with null set }
  50.    Drives := '' ;
  51.    R.AH := $0E ;                    { get maximum drive number from DOS }
  52.    R.DL := $04 ;
  53.    Intr($21,R) ;
  54.    MaxDrives := R.AL ;
  55.  
  56.    Intr($11,R) ;                    { get equipment list integer }
  57.    EquipmentList := (R.AH shl 8) OR R.AL ;
  58.    If (EquipmentList AND $01) = 0 then NumbFloppies := 0
  59.    else NumbFloppies := ((EquipmentList AND $C0) shr 6) + 1 ;
  60.  
  61.    NumbDrives := 0 ;
  62.    NumbHardDrives := 0 ;
  63.    if NumbFloppies = 1 then begin
  64.       DriveSet := DriveSet + ['A'] ;
  65.       Drives := Drives + 'A' ;
  66.       inc(NumbDrives) ;
  67.       i := 3 ;
  68.       end ;
  69.    if NumbFloppies = 2 then begin
  70.       DriveSet := DriveSet + ['B'] ;
  71.       Drives := Drives + 'B' ;
  72.       inc(NumbDrives) ;
  73.       i := 3 ;
  74.       end ;
  75.    if NumbFloppies = 3 then begin
  76.       DriveSet := DriveSet + ['C'] ;
  77.       Drives := Drives + 'C' ;
  78.       inc(NumbDrives) ;
  79.       i := 4 ;
  80.       end ;
  81.    if NumbFloppies = 4 then begin
  82.       DriveSet := DriveSet + ['D'] ;
  83.       Drives := Drives + 'D' ;
  84.       inc(NumbDrives) ;
  85.       i := 5 ;
  86.       end ;
  87.    While i <= MaxDrives do begin
  88.       R.AH := $1c ;
  89.       R.DL := i ;
  90.       Intr($21,R) ;
  91.       if R.AL <> 255 then begin
  92.          DriveSet := DriveSet + [chr(64+i)] ;
  93.          Drives := Drives + chr(64+i) ;
  94.          inc(NumbDrives) ;
  95.          inc(NumbHardDrives) ;
  96.          end ;
  97.       inc(i) ;
  98.       end ;
  99. end ;
  100.  
  101. end .